package com.eeb.dropwizardmongo.example.api;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.hibernate.validator.constraints.NotBlank;
import org.mongojack.MongoCollection;
import org.mongojack.ObjectId;

import java.util.LinkedList;
import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
@MongoCollection(name = "history")
public class History {

    @JsonProperty("_id")
    private String _id;

    @NotBlank
    @JsonProperty("name")
    private String name;

    @JsonProperty("history")
    private List<String> history = new LinkedList<>();

    public History() {
    }

    public History(@ObjectId String _id, String name) {
        this._id = _id;
        this.name = name;
    }

    @ObjectId
    public String get_id() {
        return _id;
    }

    public void set_id(String _id) {
        this._id = _id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<String> getHistory() {
        return history;
    }

    public void setHistory(List<String> history) {
        this.history = history;
    }

    public void addHistory(String history) {
        this.history.add(history);
    }

    public boolean removeHistory(String history) {
        return this.history.remove(history);
    }

    public boolean hasHistory(String history) {
        return this.history.contains(history);
    }

}